package com.knife.oauth.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.knife.common.tree.annotations.KnifeTreeId;
import com.knife.common.tree.annotations.KnifeTreeParentId;
import com.knife.common.tree.constant.KnifeRootType;
import com.knife.lov.infra.annotations.KnifeLovValue;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 菜单权限表(IamMenu)实体类
 *
 * @author tianhao.luo@hand-china.com
 * @since 2025-08-13 14:19:31
 */

@Getter
@Setter
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@Table(name = "iam_menu")
public class IamMenu {

    /*
    *  {
    path: '/message',
    component: Layout,
    name: 'Message',
    meta: { title: '消息管理', icon: 'el-icon-notebook-2' },
    children: [
      {
        path: 'message-template',
        name: 'Message-Template',
        component: () => import('@/views/system/message/template/index'),
        meta: { title: '消息模板', icon: 'el-icon-toilet-paper' }
      }
    ]
  }
    * */
    private static final long serialVersionUID = -67747601711079790L;

    public static final String FIELD_ID = "id";
    public static final String FIELD_PARENT_ID = "parentId";
    public static final String FIELD_PATH = "path";
    public static final String FIELD_COMPONENT = "component";
    public static final String FIELD_NAME = "name";
    public static final String FIELD_TITLE = "title";
    public static final String FIELD_ICON = "icon";
    public static final String FIELD_SORT = "sort";
    public static final String FIELD_HIDDEN = "hidden";
    public static final String FIELD_TYPE = "type";
    public static final String FIELD_TENANT_ID = "tenantId";

    @KnifeTreeId
    private Long id;

    @KnifeTreeParentId(rootType = KnifeRootType.NULL)
    private Long parentId;

    private String path;

    private String component;

    private String name;

    @NotBlank
    private String title;

    private String icon;

    private Integer sort;

    private Integer hidden;

    @KnifeLovValue(lovCode = "MENU_TYPE", meaningField = "typeMeaning")
    private Integer type;

    @NotNull
    private Long tenantId;

    private Long objectVersionNumber;

    private Long createdBy;

    private Date creationDate;

    private Long lastUpdatedBy;

    private Date lastUpdateDate;


    // 非数据库字段

    @TableField(exist = false)
    private String typeMeaning;
}

